package com.ljsw.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ljsw.activity.R;
import com.ljsw.entity.gpk.NotcompeteNumState;

import java.util.List;

/**
 * Created by lianchao on 2020/10/15.
 */

public class NotCompletedAdapter extends BaseAdapter {

    private List<NotcompeteNumState> LockID;
    private Context mContext;

    public NotCompletedAdapter(List<NotcompeteNumState> LockID, Context mContext) {
        super();
        this.LockID = LockID;
        this.mContext = mContext;
    }


    @Override
    public int getCount() {
        return LockID.size();
    }

    @Override
    public Object getItem(int position) {
        return LockID.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        NotCompletedAdapter.ViewHolder mviewHolder = null;
        if (mviewHolder == null) {
            mviewHolder = new NotCompletedAdapter.ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.notcompelete_listview, null, false);
            TextView notcompeteNo = (TextView) convertView.findViewById(R.id.notcompeteNo);
            TextView notcompeteNostate = (TextView) convertView.findViewById(R.id.notcompeteNostate);
//            TextView tvstate = (TextView) convertView.findViewById(R.id.PKState);
            mviewHolder.notcompeteNo = notcompeteNo;
            mviewHolder.notcompeteNostate = notcompeteNostate;
//            mviewHolder.tvstate = tvstate;
            convertView.setTag(mviewHolder);
        } else {
            mviewHolder = (NotCompletedAdapter.ViewHolder) convertView.getTag();
            convertView.setTag(mviewHolder);
        }
        mviewHolder.notcompeteNo.setText(LockID.get(position).getNotno());
        if(LockID.get(position).getState().equals("1")){
            mviewHolder.notcompeteNostate.setText("已扫描");
        }else if(LockID.get(position).getState().equals("0")){
            mviewHolder.notcompeteNostate.setText("未扫描");
        }

//        mviewHolder.tvstate.setText(LockID.get(position).getPKNotComInfo());
        return convertView;
    }


    class ViewHolder {
        private TextView notcompeteNo;
        private TextView notcompeteNostate;
//        private TextView tvstate;


    }
}
